package com.edu.zql;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.List;

/**
 * Created by User on 2017/10/11.
 */
public class TestHashMap {


    public static void main(String[] args) {


        IdentityHashMap map = new IdentityHashMap();

        Integer a = new Integer(123);
        Integer b = new Integer(123);
        Integer c = 123213;


        map.put(a, "1");
        map.put(b, "11");
        map.put(c, "111");


        System.out.println(map.get(a)); // 1
        System.out.println(map.get(b)); // 11
        System.out.println(map.get(c)); // 111

        System.out.println(map.size()); // 3


        People people = new People();
        ArrayList<Person> persons = new ArrayList<>();
        persons.add(new Person("Bob", "10"));
        persons.add(new Person("Mary", "20"));
        persons.add(new Person("Lily", "30"));

        people.persons =  persons;

        System.out.println(JSON.toJSONString(people));

    }

    static class People {
        List<Person> persons;

        public List<Person> getPersons() {
            return persons;
        }

        public People setPersons(List<Person> persons) {
            this.persons = persons;
            return this;
        }
    }


    static class Person {
        String name;
        String age;

        public Person(String name, String age) {
            this.name = name;
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public Person setName(String name) {
            this.name = name;
            return this;
        }

        public String getAge() {
            return age;
        }

        public Person setAge(String age) {
            this.age = age;
            return this;
        }
    }

}
